package controller

import (
	"mini-app/config"
	"mini-app/internal/app/admin/service"
	"strconv"

	"192.168.1.75/go-pkg/response"
	"github.com/gin-gonic/gin"
)

type Device struct{}

// List 设置列表
func (Device) List(c *gin.Context) {
	provinceID := c.Query("province_id")
	cityID := c.Query("city_id")
	districtID := c.Query("district_id")
	locationID := c.Query("location_id")
	saleStatus, _ := strconv.Atoi(c.Query("sale_status"))
	robotID := c.Query("robot_id")
	page, _ := strconv.Atoi(c.Query("page"))
	limit, _ := strconv.Atoi(c.Query("limit"))
	merchantID := c.GetString("merchant_id")
	if merchantID == "1" {
		merchantID = config.Config.MerchantID
	}
	list, total, err := service.Robot{}.List(
		c.Request.Context(),
		merchantID,
		provinceID,
		cityID,
		districtID,
		locationID,
		robotID,
		saleStatus,
		page, limit,
	)
	response.JSON(c, gin.H{
		"list":  list,
		"total": total,
	}, err)
}
